#include "kernel/types.h"
#include "user/user.h"
#include <stddef.h>
int
main(int argc, char *argv[])
{
    int p_fd[2];
    char buf[4];
    pipe(p_fd);//创建管道

    if (fork() == 0) {//子进程
        read(p_fd[0], buf, 4);//读管道
        printf("%d: received %s\n", getpid(), buf);
        write(p_fd[1], "pong", strlen("pong"));
    } else {
        write(p_fd[1], "ping", strlen("ping"));
        wait(NULL);
        read(p_fd[0], buf, 4);//buf用于存储读取的数据
        printf("%d: received %s\n", getpid(), buf);
    }
    exit(0);
}
